from django.db import models

# Create your models here.
from utils.basemodel import BaseModel
from order.models import Order


class Payment(BaseModel):
    order = models.ForeignKey(Order, on_delete=models.CASCADE, verbose_name='订单')
    order_number = models.CharField(max_length=50, verbose_name='订单号')
    pay_order_number = models.CharField(max_length=50, verbose_name='支付订单号')
    trade_no = models.CharField(max_length=50, verbose_name='交易号', null=True, blank=True)
    pay_method = models.IntegerField(choices=[(1, '支付宝'), (2, '微信')], verbose_name='支付方式', default=2)
    pay_amount = models.DecimalField(max_digits=10, decimal_places=2, verbose_name='支付金额')
    pay_status = models.IntegerField(choices=[(0, '未支付'), (1, '已支付'), (2, '已取消'), (3, '超时取消')], verbose_name='支付状态',
                                     default=0)
    pay_time = models.DateTimeField(verbose_name='支付时间', null=True, blank=True, default=None)
    pay_remark = models.CharField(max_length=255, verbose_name='支付备注', null=True, blank=True)

    class Meta:
        db_table = 'mj_payment'
        verbose_name = '支付信息'
        verbose_name_plural = verbose_name
